import math

print math.log10(10.0)
a = 0.0
try:
    r = math.log10(a)
except ValueError, error:
    print 'Warning (%s): overflow occurred. Value set to 0.0' % error.message
    # set value to 0.0 and continue
    r = 0.0
    
import warnings

def percent_range_warning(percent):
    if not 0.0 <= percent <= 100.0:
        msg = "Percent(%3.2f) is not between 0 and 100" % percent
        warnings.warn(msg, RuntimeWarning)
warnings.filterwarnings(action="ignore", category=RuntimeWarning)        
percent_range_warning(101.1)

c = 1

def foo(a, b):   
    d = a + b + c
    global c
    c = 99
    return d

print foo(2, 3)
print c

var = 0

class MyClass(object):
    #class variable
    var = 1
    
    def access_class_c(self):
        print 'class var:', self.var
        
    def access_global_c(self):
        print 'global var:', var
        
    def write_class_c(self):
        #Modify the class variable.
        MyClass.var = 2
        print 'class var:', self.var
        
    def write_instance_c(self):
        self.var = 3
        print 'instance var: ', self.var
        
obj = MyClass()

obj.access_class_c()

obj.access_global_c()

obj.write_class_c()

obj.write_instance_c()
    